package opc.read.AsyTest;

import com.alibaba.fastjson.JSON;

import java.util.LinkedHashMap;

/**
 * @Description: 测试采集信号花费的时间
 * @author: liyuan
 * @data 2021-01-12 18:43
 */
public class ShowTimes {
    public static void main(String[] args) {
        String json = "{\"PT28851A0\":1610691990711,\"PM28_SET_WIDTH1\":1610691990957,\"PT28851A2\":1610691991172,\"PM28_SET_WIDTH3\":1610691991173,\"PT28851A4\":1610691992178,\"PM28_SET_WIDTH5\":1610691992179,\"PT28851A6\":1610691993182,\"PM28_SET_WIDTH7\":1610691993183,\"PT28851A8\":1610691994186,\"PM28_SET_WIDTH9\":1610691994186}\n";
        LinkedHashMap<String, Long> linkedHashMap = JSON.parseObject(json, LinkedHashMap.class);
        Long time1 = 0L;
        Long time2 = 0L;
        //268ms
        for (int i = 0; i < linkedHashMap.size(); i++) {
            if (i % 2 == 0) {
                time1 = linkedHashMap.get("PT28851A" + i);
                time2 = linkedHashMap.get("PM28_SET_WIDTH" + (i + 1));
                System.out.println((time2 - time1) + "ms");
            }

        }

    }
}
